
#include "WorkflowPortal.h"

#include "ExtensionManager.h"
#include "ExtensionSession.h"
#include "XmlRpcServer.h"
#include "XmlRpcService.h"
#include "RsGisRpcService.h"

WorkflowPortal::WorkflowPortal(QObject *context)
    :m_context(context)
{
	initSystem();
}

void WorkflowPortal::initSystem()
{
	//read ini file
	ExtensionSession* es = ExtensionSession::instance();
	ExtensionManager* em = ExtensionManager::instance();
	em->initExtension("ExtensionConfig.ini");

	//init extension system
	//QString rpcServer = "http://localhost:8080/RPC2";
	QString rpcFreeServer = em->getFreeRpcInfo();
	XmlRpcServer* xmlRpcServer = new XmlRpcServer(8084);//RsGisLib Server 1
	xmlRpcServer->initRpc(rpcFreeServer);
	es->addObject("XmlRpcServer", xmlRpcServer);

	mainSystem();
	em->loadExtension();

	goAhead();
}

void WorkflowPortal::mainSystem()
{
	//load main windows
	RsGisRpcService* rsgis = new RsGisRpcService();
	//rsgis->initService();
}

void WorkflowPortal::goAhead()
{
	//load main windows
	//connect(this, SIGNAL(openDlg()), this, SLOT(onOpenDlg()),Qt::QueuedConnection);
}

void WorkflowPortal::handleEvent(const QObject& event)
{
    //if(event.getTopic() == "zhimakaimen")
    //{
    //    emit openDlg();
    //}

}

void WorkflowPortal::onChangeLanguage()
{
}